package com.zzw.bean;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.format.NumberFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 钱包实体类
 * 用于记录每天的收支明细
 */
@ContentRowHeight(20) // 内容行高
@HeadRowHeight(25)    // 表头行高
public class Wallet {
    @ExcelProperty(value = "记录ID")
    @ColumnWidth(10)
    private Integer id;

    @ExcelIgnore // 不导出该字段
    private Long userId;

    @ExcelProperty(value = "交易类型")
    @ColumnWidth(15)
    private Byte type;

    @ExcelProperty(value = "金额")
    @NumberFormat("#,##0.00") // 数字格式化
    @ColumnWidth(15)
    private BigDecimal amount;

    @ExcelProperty(value = "分类")
    @ColumnWidth(15)
    private String category;

    @ExcelProperty(value = "支付方式")
    @ColumnWidth(15)
    private String paymentMethod;

    @ExcelProperty(value = "事项描述")
    @ColumnWidth(30)
    private String item;

    @ExcelProperty(value = "备注")
    @ColumnWidth(50)
    private String remark;

    @ExcelIgnore // 不导出该字段
    private Byte status;

    @ExcelProperty(value = "创建时间")
    @DateTimeFormat("yyyy年MM月dd日 HH:mm:ss") // Excel导出时的日期格式，EasyExcel的注解不会干扰后端接收json数据，这些注解仅在导入导出时生效，不影响springmvc的数据绑定过程
    @ColumnWidth(25)
    //DateTimeFormat注解主要用于处理表单提交的数据绑定，对于json请求，spring默认使用Jackson进行序列化和反序列化
    //@org.springframework.format.annotation.DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    //应该@JsonFormat注解，并搭载上时区
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ExcelIgnore // 不导出该字段
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ExcelIgnore // 不导出该字段
    private List<String> selectedIds;

    // 添加日期范围查询字段，不参与序列化
    @ExcelIgnore
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date startDate;

    @ExcelIgnore
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date endDate;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Byte getType() {
        return type;
    }

    public void setType(Byte type) {
        this.type = type;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category == null ? null : category.trim();
    }

    public String getPaymentMethod() {
        return paymentMethod;
    }

    public void setPaymentMethod(String paymentMethod) {
        this.paymentMethod = paymentMethod == null ? null : paymentMethod.trim();
    }

    public String getItem() {
        return item;
    }

    public void setItem(String item) {
        this.item = item == null ? null : item.trim();
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Byte getStatus() {
        return status;
    }

    public void setStatus(Byte status) {
        this.status = status;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public List<String> getSelectedIds() {
        return selectedIds;
    }

    public void setSelectedIds(List<String> selectedIds) {
        this.selectedIds = selectedIds;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }
}
